package com.jzo2o.orders.manager.ClientApi;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.jzo2o.api.customer.dto.response.AddressBookResDTO;
import com.jzo2o.api.foundations.ServeApi;
import com.jzo2o.api.foundations.dto.response.ServeAggregationResDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class ClientApi {
    @Resource
    ServeApi serveApi;
    @SentinelResource(value = "getServeApi", fallback = "detailFallback", blockHandler = "detailBlockHandler")
    public ServeAggregationResDTO getServeApi(Long id)
    {
        ServeAggregationResDTO byId = serveApi.findById(id);
   return  byId;
    }
    public ServeAggregationResDTO detailFallback(Long id, Throwable throwable)
    {
        log.error("异常抛出");
        return null;
    }

    public  ServeAggregationResDTO detailBlockHandler(Long id, Throwable throwable)
    {
        log.error("熔断");
        return null;
    }
}
